package com.bobo.myapplication.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Toast;

import com.bobo.myapplication.R;
import com.bobo.myapplication.utils.StringUtil;

/**
 * Created by ZJB on 2018/1/2.
 *
 * @ copyright: iwhere chengdu technology
 */

public class FastClickActivity extends BaseActivity{

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fastclick);
    }

    public static void start(Context context) {
        Intent starter = new Intent(context, FastClickActivity.class);
//        starter.putExtra();
        context.startActivity(starter);
    }

    public void onClick(View view){
        switch (view.getId()){
            case R.id.btn1:
                isFastClick(view,1000);
                break;
            case R.id.btn2:
                isFastClick(view,2000);
                break;
            case R.id.btn3:
                isFastClick(view,3000);
                break;
        }
    }

    public void isFastClick(View view,long ms){
        if(StringUtil.isFastClick(view,ms)){
            Toast.makeText(this, "请不要频繁操作~", Toast.LENGTH_SHORT).show();
        }else {
            Toast.makeText(this, "正在请求网络~", Toast.LENGTH_SHORT).show();
        }
    }
}
